import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-02-29
 * Time: 18:49
 */


public class Test {
    public static void main1(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.put(1,11);
        hashBuck.put(3,44);
        hashBuck.put(5,77);
        hashBuck.put(6,88);
        hashBuck.put(9,32);
        hashBuck.put(8,41);

        Integer val = hashBuck.get(5);
        System.out.println(val);
    }

    public static void main2(String[] args) {
        Student student1 = new Student("1234");
        System.out.println(student1.hashCode());
        Student student2 = new Student("1234");
        System.out.println(student1.hashCode());

    }

    public static void main3(String[] args) {
        Student student1 = new Student("1234");
        System.out.println(student1.hashCode());
        Student student2 = new Student("1234");
        System.out.println(student1.hashCode());
        HashBuck2<Student,String> hashBuck2 = new HashBuck2<>();
        hashBuck2.put(student1,"hhh");
        String val = hashBuck2.get(student2);
        System.out.println(val);
    }

    public static void main4(String[] args) {
        Set<Integer> hashSet = new HashSet<>();
        int[] arr = {1,2,2,2,4,5,6,7,4};

        //数据去重
        /*for (int i = 0; i < arr.length; i++) {
            hashSet.add(arr[i]);
        }
        System.out.println(hashSet);*/

        //找到第一个重复元素
        /*for (int x: arr) {
            if(!hashSet.contains(x)) {
                hashSet.add(x);
            }else {
                System.out.println(x);
                return;
            }
        }*/

        //统计重复数据个数
        Map<Integer,Integer> hashMap = new HashMap<>();

        for (int x: arr) {
            if(hashMap.containsKey(x)) {
                int count = hashMap.get(x);
                hashMap.put(x,count+1);
            }else {
                hashMap.put(x,1);
            }
        }

        for(Map.Entry<Integer,Integer> entry : hashMap.entrySet()) {
            if(entry.getValue() > 1) {
                System.out.println("key: "+entry.getKey()+" val: "+entry.getValue());
            }
        }

    }

    //只出现一次的数字
    public int singleNumber(int[] num) {
        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < num.length; i++) {
            if(set.contains(num[i])) {
                set.remove(num[i]);
            }else {
                set.add(num[i]);
            }
        }
        for(int i = 0; i < num.length; i++) {
            if(set.contains(num[i])) {
                return num[i];
            }
        }
        return -1;
    }

    //随机链表的复制
    public Node copyRandomList(Node head) {
        Map<Node,Node> map = new HashMap<>();
        Node cur = head;
        while(cur != null) {
            Node node = new Node(cur.val);
            map.put(cur,node);
            cur = cur.next;
        }
        cur = head;
        while(cur != null) {
            map.get(cur).next = map.get(cur.next);
            map.get(cur).random = map.get(cur.random);
            cur = cur.next;
        }
        return map.get(head);
    }

        public static void func(String str1,String str2) {
            Set<Character> set = new HashSet<>();


            for(char ch : str2.toUpperCase().toCharArray()){
                set.add(ch);
            }

            Set<Character> set1 = new HashSet<>();
            for(char ch : str1.toUpperCase().toCharArray()){
                if(!set.contains(ch) && !set1.contains(ch)) {
                    set1.add(ch);
                    System.out.print(ch+"");
                }
            }
        }

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            // 注意 hasNext 和 hasNextLine 的区别
            while (in.hasNextLine()) { // 注意 while 处理多个 case
                String str1 = in.nextLine();
                String str2 = in.nextLine();
                func(str1,str2);
            }
        }


    public List<String> topKFrequent(String[] words, int k) {
        //1.遍历数组，统计每个单词的频率
        Map<String,Integer> hashMap = new HashMap<>();

        for (String s : words) {
            if(hashMap.get(s) == null) {
                hashMap.put(s,1);
            }else {
                hashMap.put(s,hashMap.get(s)+1);
            }
        }

        //2.建立小根堆
        PriorityQueue<Map.Entry<String,Integer>> minHeap = new PriorityQueue<>(
                k, new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if(o1.getValue().compareTo(o2.getValue()) == 0) {
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue().compareTo(o2.getValue());
            }
        }
        );

        //3.遍历hashMap,把里面数据放到小根堆
        for(Map.Entry<String,Integer> entry : hashMap.entrySet()) {
            if(minHeap.size() < k) {
                minHeap.offer(entry);
            }else {
                //小根堆放满了，下一个entry和堆顶元素比较
                Map.Entry<String,Integer> top = minHeap.peek();
                //堆顶的频率小于当前entry的频率，就出队，然后入队entry
                if(top.getValue().compareTo(entry.getValue()) < 0) {
                    minHeap.poll();
                    minHeap.add(entry);
                }else {
                    //频率相同的情况
                    if(top.getValue().compareTo(entry.getValue()) == 0) {
                        if(top.getKey().compareTo(entry.getKey()) > 0) {
                            minHeap.poll();
                            minHeap.add(entry);
                        }
                    }
                }
            }
        }
        //4.此时小根堆有了结果，需要由高到低输出
        List<String> ret =  new ArrayList<>();
        for(int i = 0; i < k; i++) {
            String key = minHeap.poll().getKey();
            ret.add(key);
        }

        //逆序
        Collections.reverse(ret);
        return ret;
    }

}
